package cn.com.egova.bouncingmenu;

import android.graphics.Color;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity implements View.OnClickListener,BouncingView.OnStatusChangeListener{
    private boolean isShow = false;
    private BouncingMenu bouncingMenu;
    private TextView tv;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        Button btn = (Button) findViewById(R.id.btn);
        btn.setOnClickListener(this);
    }


    @Override
    public void onClick(View v) {
        if(!isShow){
            isShow = true;
            ViewGroup viewGroup = (ViewGroup) LayoutInflater.from(this).inflate(R.layout.bouncing_view, null, false);
            tv = (TextView) viewGroup.findViewById(R.id.tv);
            tv.setTextSize(25);
            tv.setTextColor(Color.BLUE);

            bouncingMenu = BouncingMenu.makeMenu(this,viewGroup,this,300).show();
        }else{
            isShow = false;
            bouncingMenu.dismiss();
        }
    }

    @Override
    public void onStatusChange(BouncingView bv,BouncingView.Status status) {
        switch (status) {
            case  STATUS_SMOOTH_UP:
                tv.setText("开始视差");
                Log.e("TAG_UP:",bv.toString());
                break;
            case  STATUS_BOUNCE_DOWN:
                tv.setText("回弹结束");
                Log.e("TAG_DOWN:",bv.toString());
                break;
        }
    }
}
